/*
 *     This program is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *     You should have received a copy of the GNU General Public License
 *     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
#ifndef __COMIC_BOOK_READER_H__
#define __COMIC_BOOK_READER_H__

#include <Evas.h>
#include <Eet.h>
#define DEFAULT_WIDTH 480
#define DEFAULT_HEIGHT 500
#define ZOOM_SIZE 64
#define ANIMATOR_MAGIC 1.0f

#include <comic_book_menu.h>

typedef void (* Callback) (void *data);
Evas_Object * comic_edje_object_get(const char *name);
int WIDTH();
int HEIGHT();
int VHEIGHT();

enum READING_SEQ {
	LEFT_TO_RIGHT = 0,
	RIGHT_TO_LEFT
};

struct comic_reader_config {
	int reading_seq;
};

struct comic_page {
	Evas_Object *page;
	int x, y, w, h;
	double scale; // for image
	int page_x, page_y, page_w, page_h; // for whole page
	int ow, oh;     // The size when initial
};

int strcompare(const void *p1, const void *p2);

struct comic_book {
	char *name;
	int  index;
	int  scale;
	Evas_List *keys;
	Evas_Object *zoom;
	Eet_File *ef;
	struct comic_page *last_page;
	struct comic_page *current_page;
	struct comic_page *next_page;
};

struct comic_reader_guis {
	Evas_Object *background;
	Evas_Object *viewport;
	Evas_Object *eventsenser;
	Evas_Object *mask;
	Evas_List * list;
	struct comic_book *book;
	struct comic_reader_config *config;
};


struct Object_Shift {
	Evas_Object *obj;
	double finish_time;
	double start_time;
	int s_x;
	int s_y;
	int e_x;
	int e_y;
	Callback cb;
	void *data;
};

int animator_square_move_cb(void *object_shift);
void animator_move_object(Evas_Object *o, int (*func)(void *), double time, int sx, int sy, int ex, int ey) ;
void animator_move_object_callback(Evas_Object *o, int (*func)(void *), double time, int sx, int sy, int ex, int ey, Callback cb, void *) ;

struct comic_book * comic_book_new(const char *book);
void comic_book_free(struct comic_book *comic) ;
void comic_book_goto_index(struct comic_book *comic, int index);
void comic_book_move_to_next(struct comic_book *comic);
void comic_book_move_to_last(struct comic_book *comic);
void comic_book_pages_align(struct comic_book *comic, struct comic_reader_config *config);
void comic_book_scale_set(struct comic_book *book, int scale);
void comic_book_page_info_string_set(char *);


void comic_page_turning_detail(struct comic_page *page, int x_pos, int y_pos);
void comic_page_turning_detail_temp(struct comic_page *page, int x_pos, int y_pos);
struct comic_page *comic_book_page_get_key(struct comic_book *comic, const char *key);
struct comic_page *the_page_at_right();
struct comic_page *the_page_at_left();

void comic_page_resize(struct comic_page *ans, double w, double h) ;
struct comic_reader_config * comic_read_config_new();


Evas_List *comic_book_list(Evas_List *list, const char *directory) ;
void debug_show_string_list(Evas_List *list);

void put_mask(struct comic_reader_guis *comic);
void remove_mask(struct comic_reader_guis *comic);

#endif
